<!--
 * @Description:: 请补充填写
 * @Version: 1.0
 * @Author: 小白
 * @Date: 2022-04-12 09:13:06
 * @LastEditors: 小白
 * @LastEditTime: 2025-11-21 15:05:42
 * @FilePath: \tmsadmin\src\App.vue
-->

<template>
  <router-view />
</template>

<script lang="ts" setup>
import { onMounted, ref, onUnmounted } from 'vue'
import { store } from '@/store/index'
import { setToken } from './plugins/cookie'
import { useRouter } from 'vue-router'

const timeout = ref(null)
const timeoutDuration = ref(600000)
const router = useRouter()
onMounted(() => {
  IsPhone()
  resetTimeout()
  addEventListeners()
})
onUnmounted(() => {
  removeEventListeners()
})
const addEventListeners = () => {
  window.addEventListener('mousemove', resetTimeout)
  window.addEventListener('keypress', resetTimeout)
  window.addEventListener('click', resetTimeout)
}
const removeEventListeners = () => {
  window.removeEventListener('mousemove', resetTimeout)
  window.removeEventListener('keypress', resetTimeout)
  window.removeEventListener('click', resetTimeout)
}
const resetTimeout = () => {
  if (timeout.value) {
    clearTimeout(timeout.value)
  }
  timeout.value = setTimeout(() => {
    window.localStorage.clear()
    store.commit('setUserInfo', {})
    store.commit('setCurrPath', '')
    
    setToken('')
    router.push({ path: '/login' })
  }, timeoutDuration.value)
}
const IsPhone = () => {
  //获取浏览器navigator对象的userAgent属性（浏览器用于HTTP请求的用户代理头的值）
  var info = navigator.userAgent
  //通过正则表达式的test方法判断是否包含“Mobile”字符串
  var isPhone = /mobile/i.test(info)
  //如果包含“Mobile”（是手机设备）则返回true
  window.localStorage.setItem('isPhone', isPhone)
}
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  color: #2c3e50;
  width: 100%;
  overflow-x: hidden;
}

#nprogress .spinner {
  top: 50vh !important;
  left: 50vw !important;
  margin-left: -14px !important;
}

.optionse {
  z-index: 9999 !important;
}
</style>
<style lang="scss">
::v-deep .el-message-box {
  width: 800px !important;

  ::v-deep .el-message-box__container {
    width: 800px !important;

    ::v-deep img {
      width: 100% !important;
    }
  }
}
</style>